//
// Copyright (c) 2024 BPer
//
#ifndef SRC_BPERRTC_BPERPLAYTRACKH_H_
#define SRC_BPERRTC_BPERPLAYTRACKH_H_

#include <bperrtc/BPerRtcContext.h>

#include <bperrtp/BPerRtpPacket.h>
#include <bperrtp/BPerRtpFUAPayload2.h>
#include <bperrtp/BPerRtpSTAPPayload.h>

#include <bperutil/sys/BPerSsrc.h>
#include <bperrtc/BPerRtcStream.h>

#include <bperstream/BPerStreamType.h>

#define bPer_cache_index(x) 	 x&BPER_RTC_RECV_BUFFER_COUNT2

typedef struct  {
	BPerBool in_use;
	BPerBool end;
	uint16_t sn;
	uint32_t ts;
	int32_t nalu_type;
	int32_t nb;
	Fua2H264DataCache fua2;
	char *payload;
} BPerH264PacketCache;

typedef struct  {
	uint16_t header_sn;
	uint16_t lost_sn;
	int32_t hasReceiveStap;
	int32_t uid;
	int32_t hasRequestKeyframe;
	int64_t key_frame_ts;

	BPerRtpSTAPData stapData;
	BPerBuffer buf;
	BPerFrame videoFrame;
	char *video_buffer;
	BPerH264PacketCache cache_video_pkts[BPER_RTC_RECV_BUFFER_COUNT];

} BPerPlayTrackH264;

typedef struct  {
	BPerBool in_use;
	BPerBool end;
	uint16_t sn;
	uint32_t ts;
	int32_t nalu_type;
	int32_t nb;
	Fua2H265DataCache fua2;
	char *payload;
} BPerH265PacketCache;




typedef struct  {
	uint16_t header_sn;
	uint16_t lost_sn;
	int32_t hasReceiveStap;
	int64_t key_frame_ts;

	int32_t uid;
	//uint32_t ssrc;
	uint32_t hasRequestKeyframe;

	char *video_buffer;
	BPerRtpSTAPData stapData;
	BPerBuffer buf;
	BPerFrame videoFrame;
	BPerH265PacketCache cache_video_pkts[BPER_RTC_RECV_BUFFER_COUNT];
} BPerPlayTrackH265;

typedef struct  {
	BPerBool in_use;
	BPerBool end;
	uint16_t sn;
	uint32_t ts;
	int32_t nalu_type;
	int32_t nb;
	Fua2H264DataCache fua2;
	char *payload;
} BPerMjpegPacketCache;

typedef struct  {
	uint16_t header_sn;
	uint16_t lost_sn;

	int32_t uid;
	int32_t hasRequestKeyframe;
	int64_t key_frame_ts;


	BPerBuffer buf;
	BPerFrame videoFrame;
	char *video_buffer;
	BPerMjpegPacketCache cache_video_pkts[BPER_RTC_RECV_BUFFER_COUNT];
} BPerPlayTrackMjpeg;



#endif /* SRC_BPERRTC_BPERPLAYTRACKH_H_ */
